/**
* @author:kellen
* @contact:xiekellen@hotmail.com
* @company:achivo-gz
* @created on:
* @modified on:
*/

package com.sasis.dao.ibatis;

import java.util.List;

import com.sasis.dao.ibatis.BaseDaoiBATIS;
import com.sasis.model.VipServiceBoardingcheck;
import com.sasis.dao.VipServiceBoardingcheckDao;

import org.springframework.orm.ObjectRetrievalFailureException;

public class VipServiceBoardingcheckDaoiBatis extends BaseDaoiBATIS implements VipServiceBoardingcheckDao {

    /**
     * @see com.sasis.dao.VipServiceBoardingcheckDao#getVipServiceBoardingchecks(com.sasis.model.VipServiceBoardingcheck)
     */
    public List getVipServiceBoardingchecks(final VipServiceBoardingcheck vipServiceBoardingcheck) {
          return getSqlMapClientTemplate().queryForList("getVipServiceBoardingchecks", vipServiceBoardingcheck);
    }

    /**
     * @see com.sasis.dao.VipServiceBoardingcheckDao#getVipServiceBoardingcheck(Integer id)
     */
    public VipServiceBoardingcheck getVipServiceBoardingcheck(Integer id) {
        VipServiceBoardingcheck vipServiceBoardingcheck = (VipServiceBoardingcheck) getSqlMapClientTemplate().queryForObject("getVipServiceBoardingcheck", id);

//        if (vipServiceBoardingcheck == null) {
//            throw new ObjectRetrievalFailureException(VipServiceBoardingcheck.class, id);
//        }

        return vipServiceBoardingcheck;
    }

    /**
     * @see com.sasis.dao.VipServiceBoardingcheckDao#saveVipServiceBoardingcheck(VipServiceBoardingcheck vipServiceBoardingcheck)
     */    
    public int saveVipServiceBoardingcheck(final VipServiceBoardingcheck vipServiceBoardingcheck) {
        Integer id = vipServiceBoardingcheck.getId();
        // check for new record
        if (id == null) {
            id = (Integer) getSqlMapClientTemplate().insert("addVipServiceBoardingcheck", vipServiceBoardingcheck);
        } else {
            getSqlMapClientTemplate().update("updateVipServiceBoardingcheck", vipServiceBoardingcheck);
        }
        if( id == null ) {
            throw new ObjectRetrievalFailureException(VipServiceBoardingcheck.class, id);
        }
        return id.intValue();
    }

    /**
     * @see com.sasis.dao.VipServiceBoardingcheckDao#removeVipServiceBoardingcheck(Integer id)
     */
    public void removeVipServiceBoardingcheck(VipServiceBoardingcheck vipServiceBoardingcheck) {
        getSqlMapClientTemplate().update("deleteVipServiceBoardingcheck",  vipServiceBoardingcheck);
    }
}
